#ifndef PROTOCOL_H_
#define PROTOCOL_H_

#include <time.h>


#define NAME_CAP 32
#define PWD_CAP 32
#define OTHER_CAP 64
#define TRAINNO_CAP 8

#define INVALID_USR	-1
#define INVALID_PWD	-2
#define SERVER_BUSY	-3

typedef enum{
	ASK_LOGIN = 1,
	RPL_LOGIN,
	ASK_BOOK,
	RPL_BOOK,
	ASK_QUERY_TICKET,
	RPL_QUERY_TICKET,
	ASK_QUERY_BOOKING,
	RPL_QUERY_BOOKING,
	ASK_ENDSESSION,
	RPL_DENY
}act_t;

typedef struct protocol{
	act_t act_type;
	int usr_id;
	char usr_name[NAME_CAP];
	char usr_pwd[PWD_CAP];
	int order_no;
	time_t time_start;
	time_t time_end;
	int ticket_id;
	char train_no[TRAINNO_CAP]; 
	int ticket_count;
	char other[OTHER_CAP];
} protocol_t;


int parse_msg(protocol_t *ptc, const char * msg);

int format_msg(protocol_t *ptc, char *msg);

int empty_msg(protocol_t *ptc);

#endif /* PROTOCOL_H_ */
